package 设计模式.iterator;

import java.util.Iterator;
import java.util.List;

public class InfoCollegeIterator implements Iterator {
    List<Department> departmentsList;
    int index=-1;

    public InfoCollegeIterator(List<Department> departmentsList) {
        this.departmentsList = departmentsList;
    }

    @Override
    public boolean hasNext() {
        if (index>=departmentsList.size()-1){
            return false;
        }else {
            index+=1;
            return true;
        }
    }

    @Override
    public Object next() {
        return departmentsList.get(index);
    }

    @Override
    public void remove() {

    }
}
